<template>
  <div class="view-container BaoXiaoList">
    <header class="view-header">
      <div class="header-container">
        <div class="header-title">
          <i class="el-icon-s-grid"></i>
          <span>报销管理</span>
        </div>
        <div class="header-form">
          <div class="header-form-item">
            <el-button icon="el-icon-refresh-right" @click="refresh">刷新</el-button>
          </div>
          <div class="header-form-item">
            <el-button plain icon="el-icon-edit" type="primary" @click="openEditDialog(true)">编辑</el-button>

          </div>
          <div class="header-form-item">
            <el-button type="danger" :loading="delLoading" icon="el-icon-delete" @click="del">{{isBatchesDel}}</el-button>
          </div>
          <!--搜索-->
          <div class="header-form-item">
            <el-button type="primary" plain  icon="el-icon-search" @click="fetchData">查询</el-button>
          </div>
          <div class="header-form-item">
            <el-button type="success" icon="el-icon-plus" @click="openEditDialog(false)">报销申请</el-button>
          </div>
        </div>
      </div>
    </header>

    <section>
      <el-table
        ref="table"
        :data="tableData"
        border
        stripe
        @selection-change="handleSelectionChange"
        @row-click="handleRowClick"
      >
        <el-table-column type="selection" align="center"/>
        <el-table-column prop="baoXiaoRenName" label="经办人" width="100" align="center" />
        <el-table-column label="情况说明" align="left" >
          <template slot-scope="s">
            <el-link @click="showDetail(s.row.baoXiaoId)">{{s.row.qingKuangShuoMing}}</el-link>
          </template>
        </el-table-column>
        <el-table-column  prop="yongTu" label="用途" width="250" align="center"/>
        <el-table-column sortable prop="riQi" label="申请时间" :formatter="riQiFmt" width="150" align="center"/>
        <el-table-column sortable prop="stateName" label="状态" width="100" align="center">
          <template slot-scope="s">
            <el-tag :type="switchType(s.row.stateName)">{{s.row.stateName}}</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </section>
    <footer>
      <el-pagination
        :page-sizes="[10, 20, 50, 100]"
        layout="total, sizes, prev, pager, next, jumper"
        :total="page.total"
        :page-size="page.size"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </footer>

    <bao-xiao-save ref="save-page" @update="fetchData"></bao-xiao-save>
  </div>
</template>

<script>
  import baoXiaoAPI from '@/api/baoXiao/baoXiao'
  import BaoXiaoSave from './BaoXiaoSave'
  import listMixin from '@/mixin/listMixin'
  import flowManagerListMixin from '@/mixin/flowManagerListMixin'
  export default {
    name: 'BaoXiaoList',
    components:{BaoXiaoSave},
    mixins: [listMixin,flowManagerListMixin],
    data() {
      return {
        mixinParams: {
          addUrl: '',
          editUrl: '',
          propertyName: 'baoXiaoId',
          API: baoXiaoAPI
        }
      }
    },
    created() {
    },
    computed: {
    },
    methods: {
      showDetail(id){
        this.$router.push('/baoxiao/approval-detail/'+id+'/'+false)
      },
      fetchData() {
        baoXiaoAPI.list(this.page).then(res => {
          console.log('baoXiaoAPI.list',res)
          this.tableData = res.records
          this.page.total = res.total
        })
      },
      riQiFmt(row){
        return this._util.format(row.riQi)
      }
    }
  }
</script>

<style lang="scss">

  .BaoXiaoList {
    .el-dialog {
      width: 50%;
      .el-dialog__footer {
          padding: 10px 45px;
      }
    }
  }

</style>

